<template>
    <div>
        您好,{{username}} <br/>
        个性签名:{{sign}} <br/>

        发布文章<br/>
        <p>标签:<input type="text" v-model="form.title"></p>
        <p>内容:<input type="text" v-model="form.content"></p>
         <van-button color="linear-gradient(to right, #7232dd, #ffffff)" @click="add" style="width:200px">
                添加
          </van-button>
        
        <br/>展示文章<br/>
        <van-button @click="my">我的文章</van-button>
        <table>
            <tr>
                <td>id</td>
                <td>标题</td>
                <td>内容</td>
            </tr>
            <tr v-for="i in alist">
                <td>{{i.id}}</td>
                <td>{{i.title}}</td>
                <td>{{i.content}}</td>
            </tr>
        </table>

    </div>
</template>

<script>
    export default {
        data(){
            return{
                username:localStorage.getItem('username'),
                sign:localStorage.getItem('sign'),
                form:{'userid':localStorage.getItem('userid')},
                alist:[],
                uid:0
            }
        },
        methods:{
            add(){
                this.$axios.post('auser/articleM',this.form)
                .then(res=>{
                    if(res.data.code==200){
                        this.getlist()
                    }
                })
            },
            getlist(){
                this.$axios.get('auser/articleM?uid='+this.uid)
                .then(res=>{
                    this.alist=res.data.list
                })
            },
            //我的文章
            my(){
                this.uid=this.form.userid
                this.getlist()
            },
        },
        mounted(){
            this.getlist()
        },
    }
</script>

<style scoped>

</style>